<?php
/**
 * Created by PhpStorm.
 * User: 魏爷
 * Date: 2016/6/5
 * Time: 10:35
 */

namespace Home\Model;


class TipExperienceModel extends BaseModel
{
    // 数据表名（不包含表前缀）
    protected $tableName        =   'feel';

    /**
     * 根据条件查询信息
     * @return array()
    **/
    public function getTipFeelInfo($u_id,$feel_status){
        $where=array();
        $where['u_id']=$u_id;
        if(!empty($feel_status)){
            $where['feel_status']=$feel_status;
        }
        return $this->where($where)->order('feel_id DESC')->select();
    }
    /**
     * 根据ID查询信息
     * @return array()
    **/
    public function getBookAlianceById($feel_id){
        return $this->where("feel_id=$feel_id")->find();
    }
    /**
     * 查询心得表信息【状态为1，公开】
     * @return array()
    **/
    public function getBookForumInfo($feel_title){
        $where=array();
        $where['feel_status']=1;
        $where['feel_del']=1;
        if(!empty($feel_title)){
            $where['feel_title']=$feel_title;
        }
        return $this->where($where)->order('feel_id DESC')->select();
    }
    /**
     * 心得体会添加
     * @param Integer $feel_title 标题
     * @param Integer $feel_status 状态
     * @param String $book_name 书籍名称
     * @param Integer $book_page 页码
     * @param String $article_name 文文章名称
     * @param String $feel_intor 简介
     * @param String $feel_content 心得
     * @return boolean
     **/
    public function tipAdd($u_id,$feel_title,$feel_status,$book_name,$book_page,$article_name,$feel_intor,$feel_content){
        $data['feel_title']=$feel_title;
        $data['feel_status']=$feel_status;
        $data['book_name']=$book_name;
        $data['book_page']=$book_page;
        $data['article_name']=$article_name;
        $data['feel_intor']=$feel_intor;
        $data['feel_content']=$feel_content;
        $data['feel_time']=time();
        $data['feel_del']=1;
        $data['u_id']=$u_id;
        $res=$this->add($data);
        if($res>0){
            return true;
        }else{
            return false;
        }
    }

}